/*
 * Process.h
 *
 *  Created on: 2013-11-12
 *      Author: all
 */
#include <ctime>
#include <cstdio>
#include <vector>
#ifndef PROCESS_H_
#define PROCESS_H_

class Process {

public:
	enum OperationType {CPU, IO};
	enum TimerType {ReadyQ, CPUOperation, BlockedQ, LifeTime};
	struct Operation {
		OperationType type;
		int time;
		int orgTime;
	};
	Process(int processID);
	virtual ~Process();
	Operation getCurrentOperation();
	Process::OperationType getCurrentOperationType();
	int getCurrentOperationTime();
	int getCurrentOperationOrgTime();
	int getTotalRemainingTime();
	int getProcessID();
	int getPriorityRuntime();
	int getOperationIndex();
	void increasePriorityRuntime();
	void setPriorityRuntime(int newTime);
	bool decreaseCurrentOperationTime();
	void setNextOperation();
	bool hasNext();
	bool isFinished();
	void printDebug(); // Used for debug
	void startTimer();
	void stopTimer(TimerType type);
	double getTotalLifetime();
	double getReadyQTime();
	double getCpuTime();
	double getBlockedQTime();

private:
	std::clock_t spawnTime;
	std::clock_t startTime;
	std::clock_t stopTime;
	double lifeTime;
	double readyQTime;
	double cpuTime;
	double blockedQTime;
	int processID;
	int priorityRuntime; //how long the process has been running since added to the top priority
	int totalWaitTime;
	int processRuntime;
	int currentOperation;
	int numberOfOperations;
	Operation *operations;
	void displayOperationSummary(Operation operation);
};

#endif /* PROCESS_H_ */
